package com.itmayiedu.controller;

import com.itmayiedu.model.test.Student;
import com.itmayiedu.service.impl.StudentServiceImpl;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.CacheManager;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * *******************************************
 *
 * @description:
 * @author: by jgl
 * @date: 2018/1/28 0028 下午 2:59
 * @version:1.0 *******************************************
 */
@RestController
public class CacheController {

    private static Logger logger = Logger.getLogger(CacheController.class);

    @Autowired
    private StudentServiceImpl studentService;

    @Autowired
    private CacheManager cacheManager;

    @RequestMapping("/cache/find")
    public String find(){
        Student student =studentService.findById(1);
        System.out.println("=========="+student.getName());


        return "findSuccess";
    }

    @RequestMapping("/clear")
    public String remove(){
        cacheManager.getCache("baseCache").clear();//删除缓存
        return  "清除成功";
    }
}
